#
# Copyright (C) 2007 A Mountain Top, LLC
#
# This is free software, licensed under the MIT License
# See LICENSE.txt for more information.
#  
# $Id: Makefile 6582 2007-03-16 20:21:39Z mhostetler $
#
QCODO_NAME:=qcodo
QCODO_VERSION:=0.3.24

PKG_SOURCE:=$(QCODO_NAME)-$(QCODO_VERSION).tar.gz
PKG_DIR:=$(QCODO_NAME)-$(QCODO_VERSION)
PKG_SOURCE_URL:=http://qcodo.com/view.php/release_dev_targz/$(PKG_SOURCE)

LIB_DIR:=./includes
ASSETS_DIR:=./assets
TMP_DIR:=./tmp
PATCH_DIR:=./patches

#
# Top Level Targets
#
all: build
clean: rm_tmp clean_src 
rebuild: clean_src build

#
# Aggregate Targets
#
build: clean_src mk_tmp download_source unpack_source mk_assets cp_assets mk_lib cp_lib patch_lib
clean_src: rm_assets rm_lib

#
# Bottom Level Targets, do not call these directly
#
mk_tmp:
	if [ \! -d $(TMP_DIR) ]; then \
		mkdir $(TMP_DIR); \
	fi

mk_assets:
	if [ \! -d $(ASSETS_DIR) ]; then \
		mkdir $(ASSETS_DIR); \
	fi

mk_lib:
	if [ \! -d $(LIB_DIR) ]; then \
		mkdir $(LIB_DIR); \
	fi


rm_tmp:
	if [ -d $(TMP_DIR) ]; then \
		rm -rf $(TMP_DIR); \
	fi

rm_assets:
	if [ -d $(ASSETS_DIR) ]; then \
		rm -rf $(ASSETS_DIR); \
	fi

rm_lib:
	if [ -d $(LIB_DIR) ]; then \
		rm -rf $(LIB_DIR); \
	fi

cp_lib:
	cp -r $(TMP_DIR)/$(PKG_DIR)/wwwroot/includes/* $(LIB_DIR)/;

cp_assets:
	cp -r $(TMP_DIR)/$(PKG_DIR)/wwwroot/assets/* $(ASSETS_DIR);


download_source:
	if [ \! -f $(TMP_DIR)/$(PKG_SOURCE) ]; then \
		pushd $(TMP_DIR); \
		wget $(PKG_SOURCE_URL); \
		popd; \
	fi

unpack_source:
	if [ -f $(TMP_DIR)/$(PKG_SOURCE) ]; then \
		pushd $(TMP_DIR); \
		tar xzf $(PKG_SOURCE); \
		popd; \
	fi

patch_lib:
	patch -d $(LIB_DIR)/ < $(PATCH_DIR)/configuration.inc.php.patch; 
